﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace KiraSh.ResumeTracker
{
    public class Encryption
    {
        public static string Encrypt(string value)
        {
            CspParameters initParams = new CspParameters();
            initParams.KeyContainerName = "ResumeTracker";

            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(initParams);
            return Convert.ToBase64String(rsa.Encrypt(Encoding.Unicode.GetBytes(value), false));
        }

        public static string Decrypt(string b54value)
        {
            CspParameters initParams = new CspParameters();
            initParams.KeyContainerName = "ResumeTracker";

            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(initParams);
            return Encoding.Unicode.GetString(rsa.Decrypt(Convert.FromBase64String(b54value), false));
        }
    }
}
